home *** CD-ROM | disk | FTP | other *** search
/ Champak 43 / Vol 43.iso / games / phit.swf / scripts / __Packages / CPhitGameUI.as < prev    next >
Encoding:
Text File  |  2007-07-13  |  3.3 KB  |  112 lines

  1. class CPhitGameUI extends CMovieClipFresh
  2. {
  3.    var _calculatingSpinner;
  4.    var _buttonQuit;
  5.    var _buttonUndo;
  6.    var _buttonRedo;
  7.    var _buttonReset;
  8.    var _buttonArmorGamesLink;
  9.    var _msgBoxQuit;
  10.    var _levelString;
  11.    var _strTime;
  12.    var _strMoves;
  13.    function CPhitGameUI()
  14.    {
  15.       super();
  16.    }
  17.    function FirstFrameInitialize()
  18.    {
  19.       _root._gameUI = this;
  20.       this._calculatingSpinner._visible = false;
  21.       this._buttonQuit.Initialize("Quit",this.OnQuit);
  22.       this._buttonUndo.Initialize("Undo",this.OnUndo);
  23.       this._buttonUndo.SetEnabled(false);
  24.       this._buttonRedo.Initialize("Redo",this.OnRedo);
  25.       this._buttonRedo.SetEnabled(false);
  26.       this._buttonReset.Initialize("Reset",this.OnReset);
  27.       this._buttonReset.SetEnabled(false);
  28.       this._buttonArmorGamesLink.Initialize("Visit ArmorGames.com",this.OnArmorGames);
  29.       this._msgBoxQuit.Initialize("Quit?","Would you like to quit this game and return to the main menu? You can come back to this level later.\n\nDo you want to quit?",this.OnQuitConfirmed,this.OnQuitDenied);
  30.    }
  31.    function OnAppearDone()
  32.    {
  33.       this.stop();
  34.    }
  35.    function OnDisappearDone()
  36.    {
  37.       _root._presentation.gotoAndStop("menu");
  38.    }
  39.    function onEnterFrame()
  40.    {
  41.       super.onEnterFrame();
  42.       var _loc8_ = _root._game.GetLevel();
  43.       if(_loc8_ == undefined)
  44.       {
  45.          this._levelString = "";
  46.       }
  47.       else
  48.       {
  49.          this._levelString = String(_loc8_ + 1);
  50.       }
  51.       var _loc4_ = _root._game.GetField().GetTimeTaken();
  52.       if(_loc4_ == undefined)
  53.       {
  54.          this._strTime = "";
  55.       }
  56.       else
  57.       {
  58.          var _loc6_ = int(_loc4_ / 3600);
  59.          var _loc7_ = int(_loc4_ / 60) % 60;
  60.          var _loc5_ = int(_loc4_) % 60;
  61.          this._strTime = (_loc6_ >= 10 ? _loc6_ : "0" + _loc6_) + ":" + (_loc7_ >= 10 ? _loc7_ : "0" + _loc7_) + ":" + (_loc5_ >= 10 ? _loc5_ : "0" + _loc5_);
  62.       }
  63.       var _loc9_ = _root._game.GetField().GetNumMovesMade();
  64.       if(_loc9_ == undefined)
  65.       {
  66.          this._strMoves = "";
  67.       }
  68.       else
  69.       {
  70.          this._strMoves = String(_loc9_);
  71.       }
  72.       this._buttonUndo.SetEnabled(_root._game.IsUndoAvailable());
  73.       this._buttonRedo.SetEnabled(_root._game.IsRedoAvailable());
  74.       this._buttonReset.SetEnabled(_root._game.IsUndoAvailable());
  75.       this._calculatingSpinner._visible = !_root._game._doneShuffling && _root._game.m_nUpdates > 6;
  76.    }
  77.    function OnArmorGames()
  78.    {
  79.       _root.getURL("http://www.armorgames.com/","_blank");
  80.    }
  81.    function OnUndo()
  82.    {
  83.       _root._game.GetField().UndoLastPieceMove();
  84.    }
  85.    function OnRedo()
  86.    {
  87.       _root._game.GetField().RedoLastPieceMove();
  88.    }
  89.    function OnReset()
  90.    {
  91.       _root._game.GetField().ResetAllMoves();
  92.    }
  93.    function OnQuit()
  94.    {
  95.       FreshDebug.Trace("OnQuit");
  96.       _root._gameUI._msgBoxQuit.Show();
  97.       _root._game.GetField().SetInteractive(false);
  98.    }
  99.    function OnQuitConfirmed()
  100.    {
  101.       FreshDebug.Trace("OnQuitConfirmed");
  102.       _root._gameUI.gotoAndPlay("disappear");
  103.       _root._game.GetFieldHost().gotoAndPlay("disappear");
  104.    }
  105.    function OnQuitDenied()
  106.    {
  107.       FreshDebug.Trace("OnQuitDenied");
  108.       _root._gameUI._msgBoxQuit.Hide();
  109.       _root._game.GetField().SetInteractive(true);
  110.    }
  111. }
  112.